Return to doc.sitecore.com

Valid for Sitecore All Releases
Sitecore restart

Q:

Why does Sitecore occasionally shut down without any apparent reasons?
Why aren’t scheduled tasks executed sometimes? 

A:

As a consequence of ASP.NET architecture, ASP.NET applications start up and shut down fairly frequently. There are many reasons, such as memory cleanup and large inactivity time, why an application’s domain might suddenly be unloaded.
Some of them are as following:

  1. The web.config file was modified;
  2. Some critical files were changed (e.g. files in \bin folder);
  3. Some processModel element thresholds are exceeded and IIS Worker Process Recycling is executed.
    (for additional information go to http://msdn2.microsoft.com/en-us/library/7w2sway1(vs.80).html)

In general, it is rather difficult to determine when an application will be unloaded. A simple request is required in order for it to be restarted.
This is the reason why a Sitecore application cannot execute some scheduled tasks at the required time. It is just that there is no Sitecore application loaded at that time.
If executing a scheduled task at the specified time is critical, and there is a possibility that the server will not receive any requests for a reasonable length of time, a request should be sent manually.
This can be done by creating a custom Console Application* that sends a request and executing it using Windows Scheduled Tasks

*. There are lots of applications with similar functionality available on the web

Application code:

using System.Net;
namespace KeepAlive
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://mysite.com/sitecore");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        }
    }
}

Execute AT command to add a scheduled task:

AT hh:mm /interactive /every:M,T,W,Th,F,Su c:\myfolder\keepalive.exe